﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="add-supplier.aspx.cs" Inherits="Eisk.Web.add_supplier" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script language="javascript" type="text/javascript">
        function validate() {            
            var returnValue = true;
            var name = document.getElementById("<%=TextBoxName.ClientID%>");
            var statusTextBoxName = document.getElementById("statusTextBoxName");
            if (name.value == "") {
                statusTextBoxName.innerHTML = "Name Feild can not be blank";
                returnValue = false;
            }
            else if (name.value.length > 150) {
                statusTextBoxName.innerHTML = "Name cannot be more tha 150 character.";
                returnValue = false;
            }
            else {
                statusTextBoxName.innerHTML = "";
            }

            var email = document.getElementById("<%=TextBoxEmail.ClientID%>");
            var statusTextBoxEmail = document.getElementById("statusTextBoxEmail");

            var emailPattern = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
            var emailid = email.value;
            var matchArray = emailid.match(emailPattern);

            if (email.value == "") {
                statusTextBoxEmail.innerHTML = "Email Feild can not be blank";
                returnValue = false;
            }
            else if (matchArray == null) {
                statusTextBoxEmail.innerHTML = "Your email address seems incorrect. Please try again.";
                returnValue = false;
            }
            else {
                statusTextBoxEmail.innerHTML = "";
            }


            var zip = document.getElementById("<%=TextBoxZip.ClientID%>");
            var statusTextBoxZip = document.getElementById("statusTextBoxZip");
            var zipId = zip.value;
            if (zipId != "") {
                var isValid = /^[0-9]{5}(?:-[0-9]{4})?$/;
                matchArray = zipId.match(isValid);
                if (matchArray == null) {
                    statusTextBoxZip.innerHTML = "Zip Code not correct format.";
                    returnValue = false;
                }
                else {
                    statusTextBoxZip.innerHTML = "";
                }
            }

            return returnValue;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="clearfix align-right">
        <asp:LinkButton SkinID="LinkButton" runat="server" ID="LinkButtonViewSuppliers" Text="View Suppliers"
            OnClick="LinkButtonViewSuppliers_Click" />
    </div>
    <fieldset>
        <legend>
            <asp:Literal ID="LiteralType" runat="server" Text="Add"></asp:Literal>
            Supplier</legend>
        <div class="grid_10 inline alpha add">
            <asp:Literal ID="LiteralStatus" runat="server"></asp:Literal>
            <label>
                Name:</label>
            <span id="statusTextBoxName" class="required-field-indicator">*</span><br />
            <asp:TextBox ID="TextBoxName" runat="server" CssClass="text" MaxLength="150"> </asp:TextBox>
            <br />
            <label>
                Address:</label><br />
            <asp:TextBox ID="TextBoxAddress" runat="server" CssClass="text"></asp:TextBox>
            <br />
            <label>
                Phone:</label><br />
            <asp:TextBox ID="TextBoxPhone" runat="server" CssClass="text"></asp:TextBox><br />
            <label>
                Email:</label>
            <span id="statusTextBoxEmail" class="required-field-indicator">*</span><br />
            <asp:TextBox ID="TextBoxEmail" runat="server" CssClass="text"></asp:TextBox>
            <asp:Literal ID="LiteralTextBoxEmail" runat="server"></asp:Literal>
            <br />
            <label>
                Zip:</label>
            <span id="statusTextBoxZip" class="required-field-indicator">*</span>
            <br />
            <asp:TextBox ID="TextBoxZip" runat="server" CssClass="text"></asp:TextBox><br />
            <asp:Button ID="ButtonSaveSupplier" runat="server" Text="Save" OnClientClick="return validate()"
                OnClick="ButtonSaveSupplier_Click" CssClass="button green medium" />
        </div>
    </fieldset>
</asp:Content>
